﻿using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using LiveCharts.Definitions.Points;
using LiveCharts.Definitions.Series;
using LiveCharts.SeriesAlgorithms;
using LiveCharts.Wpf;
using LiveCharts.Wpf.Components;

namespace LiveCharts.Wpf
{
    public class GStepLineSeries : GearedSeries, IAreaPoint, IFondeable
    {
        public GStepLineSeries()
        {
            base.Model = new StepLineAlgorithm(this);
            this.method_2();
        }

        public GStepLineSeries(object configuration)
        {
            base.Model = new ScatterAlgorithm(this);
            base.Configuration = configuration;
            this.method_2();
        }

        public double PointGeometrySize
        {
            get
            {
                return (double)base.GetValue(GStepLineSeries.PointGeometrySizeProperty);
            }
            set
            {
                base.SetValue(GStepLineSeries.PointGeometrySizeProperty, value);
            }
        }


        public Brush PointForeground
        {
            get
            {
                return (Brush)base.GetValue(GStepLineSeries.PointForegroundProperty);
            }
            set
            {
                base.SetValue(GStepLineSeries.PointForegroundProperty, value);
            }
        }

        public override IChartPointView GetPointView(ChartPoint point, string label)
        {
            return this.method_3(point.View, point, label);
        }

        private void method_2()
        {
            base.SetCurrentValue(GStepLineSeries.PointGeometrySizeProperty, 8.0);
            base.SetCurrentValue(GStepLineSeries.PointForegroundProperty, Brushes.White);
            base.SetCurrentValue(Series.StrokeThicknessProperty, 2.0);
            base.SetCurrentValue(Series.FillProperty, Brushes.Transparent);
            Func<ChartPoint, string> value = new Func<ChartPoint, string>(this.method_5);
            base.SetCurrentValue(Series.LabelPointProperty, value);
            base.DefaultFillOpacity = 0.15;

        }

        private IChartPointView method_3(IChartPointView ichartPointView_0, ChartPoint chartPoint_0, string string_0)
        {
            Class12 @class = (Class12)ichartPointView_0;
            if (@class == null)
            {
                Class12 class2 = new Class12();
                class2.IsNew = true;
                class2.lineSegment_1 = new LineSegment();
                class2.lineSegment = new LineSegment();
                class2.pathFigure = base.ShapesStroke.PathFigure_0;
                @class = class2;
            }
            else
            {
                @class.IsNew = false;
                chartPoint_0.SeriesView.Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(@class.path);
                chartPoint_0.SeriesView.Model.Chart.View.EnsureElementBelongsToCurrentDrawMargin(@class.DataLabel);
            }
            if (base.PointGeometry != null && Math.Abs(this.PointGeometrySize) > 0.1 && @class.path == null)
            {
                if (base.PointGeometry != null)
                {
                    @class.path = new Path
                    {
                        Stretch = Stretch.Fill,
                        ClipToBounds = true,
                        StrokeThickness = base.StrokeThickness
                    };
                }
                base.Model.Chart.View.AddToDrawMargin(@class.path);
            }
            if (@class.path != null)
            {
                @class.path.Fill = this.PointForeground;
                @class.path.StrokeThickness = base.StrokeThickness;
                @class.path.Stroke = base.Stroke;
                @class.path.StrokeDashArray = base.StrokeDashArray;
                @class.path.Visibility = base.Visibility;
                @class.path.Width = this.PointGeometrySize;
                @class.path.Height = this.PointGeometrySize;
                @class.path.Data = base.PointGeometry;
                Panel.SetZIndex(@class.path, Panel.GetZIndex(this) + 1);
                if (chartPoint_0.Stroke != null)
                {
                    @class.path.Stroke = (Brush)chartPoint_0.Stroke;
                }
                if (chartPoint_0.Fill != null)
                {
                    @class.path.Fill = (Brush)chartPoint_0.Fill;
                }
            }
            if (base.DataLabels && @class.DataLabel == null)
            {
                @class.DataLabel = (@class.DataLabel = base.UpdateLabelContent(new DataLabelViewModel
                {
                    FormattedText = string_0,
                    Point = chartPoint_0
                }, @class.DataLabel));
            }
            if (!base.DataLabels && @class.DataLabel != null)
            {
                base.Model.Chart.View.RemoveFromDrawMargin(@class.DataLabel);
                @class.DataLabel = null;
            }
            return @class;
        }

        public double GetPointDiameter()
        {
            return this.method_4();
        }

        private double method_4()
        {
            return this.PointGeometrySize / 2.0;
        }

        [CompilerGenerated]
        private string method_5(ChartPoint chartPoint_0)
        {
            return base.Model.CurrentYAxis.GetFormatter()(chartPoint_0.Y);
        }

        public static readonly DependencyProperty PointGeometrySizeProperty = DependencyProperty.Register("PointGeometrySize", typeof(double), typeof(GStepLineSeries), new PropertyMetadata(0.0, Series.CallChartUpdater(false)));

        public static readonly DependencyProperty PointForegroundProperty = DependencyProperty.Register("PointForeground", typeof(Brush), typeof(GStepLineSeries), new PropertyMetadata(null));
    }
}
